package com.test.security.example02;

import java.security.Principal;

public class DemoPrincipal implements Principal {
    private String name;

    public DemoPrincipal(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return this.name;
    }

    public boolean equals(Object o) {
        if (o == null)
            return false;

        if (this == o)
            return true;

        if (!(o instanceof DemoPrincipal))
            return false;
        DemoPrincipal that = (DemoPrincipal) o;

        if (this.getName().equals(that.getName()))
            return true;
        return false;
    }

    public int hashCode() {
        return name.hashCode();
    }

    @Override
    public String toString() {
        return "DemoPrincipal{" +
                "name='" + name + '\'' +
                '}';
    }
}
